package net.framework.smc.demo.dao;

import net.framework.smc.demo.po.Trip;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * @authore zyx
 * @date 2018/6/28 15:24
 */
//@Component
public interface TripJpa extends JpaRepository<Trip, String>, JpaSpecificationExecutor<Trip> {

    @Query(value = "select id,title,start_time startTime,end_time endTime,create_time  createTime, owner,del_flag delFlag, status from t_trip where owner=?1 and status=?2 and date_format(start_time,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d') and del_flag=0", nativeQuery = true)
    List<Map<String, String>> findByStatus(String userId, String status) throws Exception;
}
